﻿<!--#include file="const.inc"-->

<%
	dim rs,sql,i

select case v
case "0"
we0="<br/>"
hr="------------<br/>"
%>
<card title="申请友链"><p align="<%=qingtian.px%>">
<%
case "1"
hr=""
zi="<span style=""color:#FF5500"">"
zi0="</span>"
we="<div class=""footer"">"
sou="<div class=""block4"">"
dao="<div class=""navi"">"
we0="</div>"
%>
<title>申请友链</title>
</head>
<body>
<%

End Select
	%><%
	if Request.QueryString("Action")="save" then
		if trim(qingtian.repsql(Request.form("name")))<>"" and trim(qingtian.repsql(Request.form("classid")))<>"" and trim(qingtian.repsql(Request.form("mainname")))<>"" and trim(qingtian.repsql(Request.form("urls")))<>"" then

			Set Rs = Server.CreateObject("Adodb.Recordset")
			Sql = "select [id],[name],[urls],[main],[classid],[show] from [qingtian_link_list] where name='"&trim(qingtian.repsql(Request.form("name")))&"' or urls='"&trim(qingtian.RepSQL(Request.form("urls")))&"'"
			Rs.Open Sql,conn,1,3
			if not (rs.bof and rs.eof)  then
				%><%=we%>已存在该网站!请不要重复提交!<%=we0%><%
			else
				set rs8=Server.CreateObject("Adodb.Recordset")
  				sql8="select top 1 id,sidd FROM [qingtian_user] where [bbs]=true order by id asc"
  				rs8.open sql8,conn,1,1
                                if not (rs8.bof and rs8.eof)  then
                                qingtian.addnfo(rs8("id")&"tt"&"站长你好!有人在你的网站里申请了友链快去看看吧![br][url=/link/?sid=[sid]]进入查看最新友链[/url]")
                                end if
                                rs8.close
                                set rs8=nothing
				rs.addnew
				rs("name")=trim(qingtian.repsql(Request.form("name")))
				if instr(trim(qingtian.repsql(Request.form("urls"))),"http://")>0 then
				rs("urls")=trim(qingtian.repsql(Request.form("urls")))
				else
				rs("urls")="http://" & trim(qingtian.repsql(Request.form("urls")))
				end if
				rs("main")=trim(qingtian.repsql(Request.form("mainname")))
				rs("classid")=trim(qingtian.repsql(Request.form("classid")))
				rs("show")=0
				rs.update
				%><%=we%>已提交友链!请等待审批!你的返回地址为http://<%=Request.ServerVariables("SERVER_NAME")%>/link/to.asp?id=<%=rs("id")%><%=we0%><%
			end if
			Rs.close

			set rs=nothing

  
		else	
			%><%=we0%>内容不能为空!<%=we0%><%=sou%><a href='add.asp?sid=<%=sidd%>'>返回修改</a><%=we0%><%
		end if
	else
Response.Write(""&dao&"<b><a href=""/index.asp?sid="&sidd&""">首页</a>&gt;<a href=""index.asp?sid="&sidd&""">友链首页</a>&gt;申请</b>"&we0&""&hr&""&we&"")
        if v=1 then
	%>
        <form action="add.asp?Action=save&amp;sid=<%=sidd%>" method="post">
        <%
        end if
        %>
	选择分类:
	<%
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select [id],[name] from [qingtian_link_class]"
	Rs.Open Sql,conn,1,3
	if not (rs.bof and rs.eof)  then

	%><select name="classid" value="<%=rs("id")%>"><%
		For i=1 to rs.RecordCount
	%>
		<option value="<%=rs("id")%>"><%=qingtian.utf8(rs("name"))%></option>
	<%
		Rs.MoveNext
		next
	else
	%><select name="classid" value="">
		<option value="">选择分类</option><%
	end if
	Rs.close
	set rs=nothing
	%>
	</select><br/>

	网站名称：<input emptyok="true"  name="name" type="text" maxlength="50"  /><br/>
	网站短名：<input emptyok="true"  name="mainname" type="text" maxlength="2" />最多2个汉字<br/>
	网站地址：<input emptyok="true"  name="urls" type="text" maxlength="255" /><br/>
        <%
        if v=0 then
	%>        
	<anchor>提交
    	<go href="add.asp?Action=save&amp;sid=<%=sidd%>" method='post'>
        <postfield name="name" value="$(name)"/>
        <postfield name="mainname" value="$(mainname)"/>
        <postfield name="urls" value="$(urls)"/>
        <postfield name="classid" value="$(classid)"/>
    	</go>
	</anchor>
        <%
        else
	%>
        <input type="submit" value="提交"/>
        </form>
	<%
	end if
	end if
        Response.Write we0
%>
<%=hr%>
<%=sou%><a href='index.asp?sid=<%=sidd%>'>返回友链首页</a><%=we0%>
 
		<%

end Function
%>
